package org.xm.sk.vo.ob;

import java.util.HashSet;
import java.util.Set;

import org.xm.sk.vo.tb.Image;
import org.xm.sk.vo.tb.Shop;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel(value = "LocalShopList", description = "门店基本信息")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LocalShopList {

    @ApiModelProperty(value = "门店ID")
    Integer id;

    @ApiModelProperty(value = "门店名称")
    String name;

    @ApiModelProperty(value = "门店的粉丝数")
    Long fansCount;

    @ApiModelProperty(value = "门店的满意度")
    String starlevel;

    @ApiModelProperty(value = "门店地址")
    String address;

    @ApiModelProperty(value = "门店与用户之间的距离")
    Double distance;

    @ApiModelProperty(value = "门店相关图片ID集")
    Set<Integer> imageIds = new HashSet<Integer>(0);

    @ApiModelProperty(value = "此用户是否已关注此门店")
    Boolean isAt;
    
    public LocalShopList(Integer id, String name, String starlevel, String address, Shop s) {
        this.id = id;
        this.name = name;
        this.fansCount = (long) s.getFans().size();
        this.starlevel = starlevel;
        this.address = address;
        for (Image i : s.getImages()) {
            this.imageIds.add(i.getId());
        }
    }
    
    public void setDistance(Double distance) {
        this.distance = Double.parseDouble(String.format("%.2f", distance));
    }

}